Repository navigation
feat(autoware_ndt_scan_matcher_common): add the NDT backend interface - #1559
Merged
mitsudome-r merged 2 commits intoNov 24, 2026
Merged
Conversation
|
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
xmfcx
marked this pull request as ready for review
November 23, 2026 14:34
xmfcx
requested review from
Motsu-san,
TaikiYamada4,
YamatoAndo and
mitsudome-r
November 23, 2026 14:34
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/ndt-backend-parameter #1559 +/- ##
=============================================================
Coverage ? 72.59%
=============================================================
Files ? 500
Lines ? 27778
Branches ? 13128
=============================================================
Hits ? 20165
Misses ? 7531
Partials ? 82
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
xmfcx
force-pushed
the
feat/ndt-backend-interface
branch
from
November 23, 2026 14:43
a18ea3d to
bfe2a6d
Compare
xmfcx
force-pushed
the
feat/ndt-backend-interface
branch
from
November 23, 2026 15:28
bfe2a6d to
235c10c
Compare
Add the header-only package autoware_ndt_scan_matcher_common with the interface NdtBackend and its types NdtParams and NdtResult. The next change makes autoware_ndt_scan_matcher load its NDT implementation through this interface with pluginlib, and other packages can then add implementations. A backend package depends only on this package. The comments state the contract of a backend: how to compute each score and field of NdtResult, how ndt_omp builds the voxels, instances, threads, the order of calls, exceptions, copies, the regularization and the lifetime of the library. The README shows a complete backend package. The interface is in an inline namespace whose name holds its version, the static alignment of Eigen and the heap allocator of Eigen. A backend that was built against another version, or with options that change the alignment or the allocator (for example AVX), has other symbols, and the node cannot create it. A test loads fake backends with other configurations and expects this failure. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
…review notes Export the INTERFACE target autoware_ndt_scan_matcher_common::autoware_ndt_scan_matcher_common, and use target_link_libraries() in the README example. ROS 2 Lyrical removes ament_target_dependencies(). State in the comments that the node also calls clone() on the instance of the map update thread, and which yaw the regularization uses. State in the README that the node and the backend must use the same PCL. Count the libraries with another Eigen configuration in their own test, so that a gtest filter does not make the test fail. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
xmfcx
force-pushed
the
feat/ndt-backend-interface
branch
from
November 23, 2026 17:45
286cc98 to
a8ddf9b
Compare
This was referenced Nov 23, 2026
mitsudome-r
reviewed
Nov 24, 2026
| /// The backend can keep the cloud. The node takes the ids from the map loader and does not | ||
| /// examine them. Normally, each map_id is unique among the added clouds and remove_target() gets | ||
| /// only ids that were added. remove_target() must ignore an id that was not added. | ||
| virtual void add_target( |
Member
There was a problem hiding this comment.
Maybe we could rename this to add_map instead of add_target to make it more obvious, but that can come after all the migration to pluginlib is done.
YamatoAndo
approved these changes
Nov 24, 2026
mitsudome-r
approved these changes
Nov 24, 2026
xmfcx
added a commit
to xmfcx/ndt_cuda
that referenced
this pull request
Nov 24, 2026
The interface merged in autowarefoundation/autoware_core#1559, but no release of Autoware Core has it yet. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
xmfcx
added a commit
to open-localization/ndt_cuda
that referenced
this pull request
Nov 24, 2026
* feat: add the package ndt_cuda_autoware_backend The package is the NDT backend ndt_cuda for autoware_ndt_scan_matcher. It wraps MultiGridNormalDistributionsTransformCUDA behind the NdtBackend interface of autoware_ndt_scan_matcher_common. Autoware loads it with pluginlib when the parameter ndt.backend is ndt_cuda, so no file of Autoware changes. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * refactor(ndt_cuda_autoware_backend): use the new name ndt_omp of the CPU backend in the tests Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * style(pre-commit): autofix Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * fix(integrations): stop apply.sh on Autoware Core with the NDT backend interface On such a version, the package ndt_cuda_autoware_backend loads ndt_cuda as a plugin, so the patch of the node source is not necessary. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * docs: say that only autoware_core main has the NDT backend interface The interface merged in autowarefoundation/autoware_core#1559, but no release of Autoware Core has it yet. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * ci: run the build jobs for changes to ndt_cuda_autoware_backend Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * fix(ndt_cuda): give a copy its own point indices pcl::PCLBase copies the pointer to the point indices, and each align() resizes them. So a copy and its original that aligned in two threads raced on one vector, and the process could crash. The copy constructor and the assignment now copy the indices. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * fix(ndt_cuda_autoware_backend): give the result of ndt_omp when the map has no voxels Without a usable map, align() now returns the guess, the scores 0 and arrays of one value, as the backend ndt_omp does. Before, the arrays were empty or too short, and the node wrote a warning to the diagnostics for each scan. The tests now also: - align the original and its clone at the same time - compare the score functions after align(), as the node uses them - use a regularization pose away from the true pose - fail, not skip, if initialize() fails on a computer with a CUDA device The package declares its direct dependencies eigen and libpcl-all-dev. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * docs: run rosdep only for the library, and name all packages in the Eigen note rosdep over the whole repository also reads the backend package, and it fails without Autoware. The note about the alignment of Eigen now names ndt_cuda too, because a mismatch there is not found at load time. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * fix(ndt_cuda_autoware_backend): do not keep the source cloud after align() The interface does not let a backend keep the source after align() returns, but pcl::Registration keeps it until the next align(), and clone() copied it. The backend now drops it after each align(). The tests now also: - update a clone of the active instance in another thread, as the incremental map update of the node does - align the original and its clone 500 times each, not 100 - make sure that a change of the original does not change a clone - align without voxels only while has_target() is true, as the node does Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * docs(integrations): hide the backend package in a workspace of an Autoware release Without the NDT backend interface, the package ndt_cuda_autoware_backend does not build, and rosdep cannot resolve autoware_ndt_scan_matcher_common. A COLCON_IGNORE file hides it from colcon and rosdep. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> * test(ndt_cuda_autoware_backend): make sure that align() does not keep the source Also use the PCL dependency tags of autoware_ndt_scan_matcher (libpcl-all, and libpcl-all-dev only to build), and say that ndt.num_threads has no effect in this backend, also for the CPU voxel build. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org> --------- Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
5 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR replaces the PR below. GitHub closed that PR as merged when I reordered the stack.
This PR adds the header-only package
autoware_ndt_scan_matcher_commonwith the NDT backend interface. The top PR of this stack makesautoware_ndt_scan_matcherload its NDT implementation through this interface with pluginlib. Then other packages, for example a GPU implementation in the Autoware Index, can add backends. A backend package depends only on this package, not on the node.The package holds:
autoware::ndt_scan_matcher::NdtBackend(ndt_backend.hpp): the interface. Its comments state the contract of a backend: instances, threads, the order of calls, exceptions, copies, the regularization and the lifetime of the library.NdtParamsandNdtResult(ndt_types.hpp): the parameters and the result of an alignment. They are new types, not the types of ndt_omp, so later changes in ndt_omp do not change the interface. The comments ofNdtResultstate how a backend must compute each score and how ndt_omp builds the voxels, because the node compares the scores with thresholds that are tuned for ndt_omp. They also state how the node uses each field. For example, an emptytransformation_arraychanges which alignments the node accepts.autoware_ndt_scan_matcher_common::autoware_ndt_scan_matcher_common. It gives the include folder, Eigen and thecommoncomponent of PCL. A backend links it with${autoware_ndt_scan_matcher_common_TARGETS}, so the README example works withoutament_target_dependencies(), which ROS 2 Lyrical removes.CMakeLists.txtandplugins.xmlexamples, a naming rule for backends, the compile options, and the rule for changing the version of the interface.The types and the interface are in an inline namespace (
v1_eigen_align_16_malloc_stdon x86_64 with the options of Autoware). Its name holds the version of the interface, the static alignment of Eigen (EIGEN_MAX_STATIC_ALIGN_BYTES) and the heap allocator of Eigen. A backend that was built against another version, or with options that change the alignment or the allocator (for example AVX or the address sanitizer of GCC), has other C++ symbols. Then the node cannot load it, and the error says why. Without this, the node and the backend read the same memory with different layouts, or one side frees memory with another allocator than the side that allocated it.How the node uses a backend
The node has two instances of the backend: the active instance, and the instance that the map update thread builds. The interface follows the three places where the node calls them. The top PR of this stack connects the node to the interface.
How a package adds a backend
The README has these steps with complete
CMakeLists.txtandplugins.xmlexamples.Before and after
The top PR of this stack connects the node to this interface.
Related links
Parent Issue:
Discussion:
How was this PR tested?
See the Verification block at the end.
Notes for reviewers
pluginlib_export_plugin_description_file(autoware_ndt_scan_matcher_common <file>.xml), because pluginlib expects the package that holds the base class.ament_export_dependencies(), not only itscommoncomponent. A package that first finds only some components of PCL can miss the targets of the other components when it finds PCL again. I saw this withpcl_ros(QHULL::QHULLnot found). The target of the package links onlypcl_common, and the README says that a backend links the other components that it uses.ament_export_targets()by hand. The flagEXPORT_LIBRARY_TARGETSof the target export plan exports only libraries thatament_auto_add_library()adds. The README example links${<pkg>_TARGETS}without a scope keyword, as the plan decides for consumers:nvcc. The inline namespace catches the options that do change it. Thepcl_commontarget passes on the compile options of PCL, which are empty in the Ubuntu 22.04 and 24.04 packages.Interface changes
C++ interface
autoware::ndt_scan_matcher::NdtBackend,NdtParamsandNdtResultin the new packageautoware_ndt_scan_matcher_common.Effects on system behavior
None. No package uses the interface yet.
AI usage
AI usage: Written with Claude Code. I set the design and the requirements. Claude Code wrote the code, the tests and this description.
Self-review: Three review rounds with a clean context read the full diff, the earlier review comments, the node code of the top PR, and this description. The review found no correctness bug. It found one risk (the README example used
ament_target_dependencies(), which ROS 2 Lyrical removes) and five small notes on comments, the test and the README. All six findings are fixed in the last commit.Verification: On Jazzy, the package builds, and `colcon test-result` reports 23 results with 0 failures. A backend package that copies the README example builds in both install modes, and pluginlib loads it. Humble ran only in CI, and Lyrical did not run.
Build and tests
Jazzy, x86_64, an incremental build in the local workspace, at the top of the stack. There, the files of this package equal this PR at
286cc98a. The current heada8ddf9b6has the same files: GitHub rebased it onmainafter the rename PR merged. The dependencies came from a local workspace install.colcon build --symlink-install --packages-select autoware_ndt_scan_matcher_common autoware_ndt_scan_matcher --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=--coverage:Summary: 2 packages finished [49.7s].colcon test --packages-select autoware_ndt_scan_matcher_common autoware_ndt_scan_matcher --event-handlers console_cohesion-, thencolcon test-result --test-result-base build/autoware_ndt_scan_matcher_common:Summary: 23 tests, 0 errors, 0 failures, 4 skipped.test_ndt_backend_abi --gtest_filter='*/0':[ PASSED ] 1 test.Before the last commit, the same filter printedExpected: (refused_count) >= (3), actual: 0 vs 3.ABI guard
test_ndt_backend_abibuilds the same fake backend seven times as a plugin library: with no definition of its own, with a static alignment of 0, 16, 32 and 64 bytes, and with each of the two allocators of Eigen. class_loader must create a backend only from a library with the Eigen configuration of the test. A separate test makes sure that at least 3 libraries have another configuration. The file has 8 tests.[ FAILED ] 4 tests(align_0,align_32,align_64,allocator_eigen).-DCMAKE_CXX_FLAGS=-mavxand a build with-DCMAKE_CXX_FLAGS=-fsanitize=address: 8 passed in each.nm -DCshows the namespacesv1_eigen_align_32_malloc_eigenandv1_eigen_align_16_malloc_eigenin these builds.A backend package from the README
my_packagewith theCMakeLists.txtandplugins.xmlof the README, and a small loader package that linksautoware_ndt_scan_matcher_common::autoware_ndt_scan_matcher_common.--symlink-installand with a copy install, the loader printedLOADED name=my max_iterations=30 has_target=1 poses=1 points=1.my_package, the same backend built with-mavxon the backend only did not load:Could not create object of class type my_package::MyNdtBackend as no factory exists for it.ament_target_dependencies(), but no Lyrical build confirms it.With the top PR of this stack
On an earlier version of the stack, before the rebase on the diagnostics change. The README example then still used
ament_target_dependencies().-mavxdoes not load, and the node stops with this message:Failed to create the NDT backend 'stub'. [...] The backend was possibly built against another version of autoware_ndt_scan_matcher_common, or with SIMD options that change the alignment of Eigen (for example AVX), [...]ndt_cuda_autoware_backend, a wrapper of about 180 lines) implements the interface without a change to the interface or to the node. In open loop on the sample rosbag with a tiled map, the node with this backend takes a median of 0.40 ms per scan, against 3.75 ms withndt_omp. The largest position difference tondt_ompis 1.2 cm.CI
On this head
a8ddf9b6:clang-tidy-diffpasses on Humble and Jazzy.pre-commit-optionalfails on two dead links inlocalization/autoware_pose_initializer/README.md, which this PR does not touch.